package com.project.spring.dao.impl;

import com.project.spring.dao.IAccountDao;
import com.project.spring.domain.Account;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

public class AccountDaoImpl implements IAccountDao {


    public void setRunner(QueryRunner runner) {
        this.runner = runner;
    }

    private QueryRunner runner;


    @Override
    public List<Account> findAllAccount() {
        try {
            List<Account> accountList = runner.query("select * from account", new BeanListHandler<Account>(Account.class));
            return accountList;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Account findAccountById(Integer accountId) {
        return null;
    }

    @Override
    public void saveAccount(Account account) {

    }

    @Override
    public void updateAccount(Account account) {

    }

    @Override
    public void deleteAccount(Integer acccountId) {

    }
}
